package cn.wzl.getapmac;

import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
class WifiScanReceiver extends BroadcastReceiver {
	WifiManager wifiManager;
	WifiScanReceiverSink wifiScanReceiverSink = null;

	WifiScanReceiver(WifiManager wifiManager,
			WifiScanReceiverSink wifiScanReceiverSink) {
		this.wifiManager = wifiManager;
		this.wifiScanReceiverSink = wifiScanReceiverSink;
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		String action = intent.getAction();
		if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) {
			if (wifiManager != null && wifiScanReceiverSink != null)
				wifiScanReceiverSink.onScanFinish(wifiManager.getScanResults());
		}
	}

	static interface WifiScanReceiverSink {
		void onScanFinish(List<ScanResult> scanResult);
	}

}
